package com.itheima.stock.job;

import com.itheima.stock.service.StockTimeTaskService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class StockJob {

    @Autowired
    private StockTimeTaskService stockTimeTaskService;

    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("myJobHandler")
    public void demoJobHandler() throws Exception {
        System.out.println("当前时间jobzzz:" + DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
    }

    /**
     * 定时采集a股数据
     *
     * @throws Exception
     */
    @XxlJob("getInnerMarketInfo")
    public void getStockInner() throws Exception {
        stockTimeTaskService.getInnerMarketInfo();
    }

    /**
     * 定时采集个股数据
     *
     * @throws Exception
     */
    @XxlJob("getStockRtInfo")
    public void getStockRtInfo() throws Exception {
        stockTimeTaskService.getStockRtInfo();
    }

    /**
     * 板块定时任务
     */
    @XxlJob("getStockBlock")
    public void getStockBlock() {
        stockTimeTaskService.getStockBlock();
    }

    /**
     * 国外大盘股
     */
    @XxlJob("getStock_outer_market_index_info")
    public void getStockOut() {
        stockTimeTaskService.getStock_outer_market_index_info();
    }

}
